﻿<Page xmlns:Helpers="using:LayoutGridview.Helpers" 
    xmlns:ViewModels="using:LayoutGridview.ViewModels"
    x:Class="LayoutGridview.Views.GridView03"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:LayoutGridview.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.DataContext>
        <ViewModels:GridView03ViewModel/>
    </Page.DataContext>

    <Page.Resources>
        <CollectionViewSource x:Name="MyCsv" 
                              d:Source="{Binding Data, Source={d:DesignInstance Type=ViewModels:GridView03ViewModel, IsDesignTimeCreatable=True}}"
                              Source="{Binding Data}" />
    </Page.Resources>

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">

        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="320" />
        </Grid.ColumnDefinitions>

        <TextBlock Style="{StaticResource HeaderTextBlockStyle}" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="120,40,0,100">
            GridView items can vary in size
        </TextBlock>
        <Helpers:GridView ItemsSource="{Binding Source={StaticResource MyCsv}}" Padding="120,140,80,80">
            <GridView.ItemTemplateSelector>
                <Helpers:TemplateSelector>
                    <Helpers:TemplateSelector.NormalTemplate>
                        <DataTemplate>
                            <Grid Background="{Binding Brush}" Height="50" Width="200">
                                <TextBlock FontSize="20" Text="{Binding Text}" VerticalAlignment="Top" Margin="11" Foreground="Gainsboro" />
                                <TextBlock FontSize="20" Text="{Binding Text}" VerticalAlignment="Top" Margin="10" Foreground="Black" />
                            </Grid>
                        </DataTemplate>
                    </Helpers:TemplateSelector.NormalTemplate>
                    <Helpers:TemplateSelector.LargeTemplate>
                        <DataTemplate>
                            <Grid Background="{Binding Brush}" Height="200" Width="400">
                                <TextBlock FontSize="20" Text="{Binding Text}" VerticalAlignment="Top" Margin="11" Foreground="Gainsboro" />
                                <TextBlock FontSize="20" Text="{Binding Text}" VerticalAlignment="Top" Margin="10" Foreground="Black" />
                            </Grid>
                        </DataTemplate>
                    </Helpers:TemplateSelector.LargeTemplate>
                </Helpers:TemplateSelector>
            </GridView.ItemTemplateSelector>
            <Helpers:GridView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VariableSizedWrapGrid ItemHeight="50" ItemWidth="200" MaximumRowsOrColumns="8" />
                </ItemsPanelTemplate>
            </Helpers:GridView.ItemsPanel>
        </Helpers:GridView>


        <Rectangle Grid.Column="1" Fill="{StaticResource SemanticZoomButtonPressedBackgroundThemeBrush}" />
        <ListView ItemsSource="{Binding Source={StaticResource MyCsv}}" Padding="40,40,40,80" Grid.Column="1">
            <ListView.Header>
                <TextBlock Style="{StaticResource HeaderTextBlockStyle}" Margin="0,0,0,60">ListView</TextBlock>
            </ListView.Header>
            <ListView.ItemTemplateSelector>
                <Helpers:TemplateSelector>
                    <Helpers:TemplateSelector.NormalTemplate>
                        <DataTemplate>
                            <Grid Background="{Binding Brush}" Height="50" Width="220">
                                <TextBlock FontSize="20" Text="{Binding Text}" VerticalAlignment="Top" Margin="11" Foreground="Gainsboro" />
                                <TextBlock FontSize="20" Text="{Binding Text}" VerticalAlignment="Top" Margin="10" Foreground="Black" />
                            </Grid>
                        </DataTemplate>
                    </Helpers:TemplateSelector.NormalTemplate>
                    <Helpers:TemplateSelector.LargeTemplate>
                        <DataTemplate>
                            <Grid Background="{Binding Brush}" Height="150" Width="220">
                                <TextBlock FontSize="20" Text="{Binding Text}" VerticalAlignment="Top" Margin="11" Foreground="Gainsboro" />
                                <TextBlock FontSize="20" Text="{Binding Text}" VerticalAlignment="Top" Margin="10" Foreground="Black" />
                            </Grid>
                        </DataTemplate>
                    </Helpers:TemplateSelector.LargeTemplate>
                </Helpers:TemplateSelector>
            </ListView.ItemTemplateSelector>
        </ListView>

    </Grid>


</Page>